#ifndef SYSCONSTANTS_H
#define SYSCONSTANTS_H

#pragma once

#include <QObject>
#include <QtQml/qqml.h>
#include "singleton.h"

class SysConstants : public QObject
{
    Q_OBJECT
    QML_ELEMENT         // 注册为QML类型
    QML_SINGLETON       // 声明为单例

    struct SysConst
    {
        QString sysName = "expertin";
        QString displayName = "信息管理系统";
        QString company = "Greatsky工作室";
        QString sysVersion = "6.0.0";
        QString sysCopyright = "© 2025 Greatsky Technologies";
        QString licenseInfo = "Mit";
        QString sysCopyrightUrl = "www.greatsky.tech";
        QString sysDescription =  "信息管理系统 桌面版\n版本: 6.0.0(Qt5.15.2)";
    };

    // 系统常量属性
    Q_PROPERTY(QString sysName READ sysName CONSTANT)
    Q_PROPERTY(QString displayName READ displayName CONSTANT)
    Q_PROPERTY(QString company READ company CONSTANT)
    Q_PROPERTY(QString sysVersion READ sysVersion CONSTANT)
    Q_PROPERTY(QString sysCopyright READ sysCopyright CONSTANT)
    Q_PROPERTY(QString licenseInfo READ licenseInfo CONSTANT)
    Q_PROPERTY(QString sysCopyrightUrl READ sysCopyrightUrl CONSTANT)
    Q_PROPERTY(QString sysDescription READ sysDescription CONSTANT)

    // 密码处理使用函数而不是属性（安全考虑）
    Q_INVOKABLE QString getDefaultPassword() const;

public:
    SINGLETON(SysConstants)
    SysConstants(const SysConstants&) = delete;
    SysConstants& operator=(const SysConstants&) = delete;

    // 属性访问器
    QString sysName() const;
    QString displayName() const;
    QString company() const;
    QString sysVersion() const;
    QString sysCopyright() const;
    QString licenseInfo() const;
    QString sysCopyrightUrl() const;
    QString sysDescription() const;

    // 单例实例提供函数
    // static SysConstants* instance(QQmlEngine* engine, QJSEngine* scriptEngine);
private:
    explicit SysConstants(QObject* parent = nullptr);
    ~SysConstants() = default;

    // 静态常量结构体实例
    static const SysConst constants;
};

#endif // GLOBALCONSTS_H
